﻿using PARK.Common.Const;
using SqlSugar;
using System;
using Yitter.IdGenerator;

namespace PARK.CardAcct.Entitys
{
    /// <summary>
    /// 卡户日志
    /// </summary>
    [SugarTable("base_employee_log")]
    [Tenant(ClaimConst.TENANT_ID)]
    public class EmployeeLogEntity
    {
        /// <summary>
        /// 日志Id
        /// </summary>
        [SugarColumn(ColumnName = "logId", IsPrimaryKey = true)]
        public string LogId { get; set; }
        
        /// <summary>
        /// 卡户Id
        /// </summary>
        [SugarColumn(ColumnName = "AcctId")]        
        public string AcctId { get; set; }
        
        /// <summary>
        /// 工号
        /// </summary>
        [SugarColumn(ColumnName = "JobNo")]        
        public string JobNo { get; set; }
        
        /// <summary>
        /// 姓名
        /// </summary>
        [SugarColumn(ColumnName = "ReallName")]        
        public string ReallName { get; set; }
        
        /// <summary>
        /// 部门Id
        /// </summary>
        [SugarColumn(ColumnName = "DepartId")]        
        public string DepartId { get; set; }
        
        /// <summary>
        /// 部门
        /// </summary>
        [SugarColumn(ColumnName = "DepartName")]        
        public string DepartName { get; set; }
        
        /// <summary>
        /// 卡号
        /// </summary>
        [SugarColumn(ColumnName = "CardNo")]        
        public string CardNo { get; set; }
        
        /// <summary>
        /// 新卡卡号
        /// </summary>
        [SugarColumn(ColumnName = "NewCardNo")]        
        public string NewCardNo { get; set; }
        
        /// <summary>
        /// 类别;1开户发卡;2挂失、3解挂、4冻结、5解冻、6补卡、7销户
        /// </summary>
        [SugarColumn(ColumnName = "LogKind")]        
        public int? LogKind { get; set; }
        
        /// <summary>
        /// 
        /// </summary>
        [SugarColumn(ColumnName = "LogKindName")]        
        public string LogKindName { get; set; }
        
        /// <summary>
        /// 
        /// </summary>
        [SugarColumn(ColumnName = "Summary")]        
        public string Summary { get; set; }
        
        /// <summary>
        /// 
        /// </summary>
        [SugarColumn(ColumnName = "CreateDate")]        
        public DateTime? CreateDate { get; set; }
        
        /// <summary>
        /// 
        /// </summary>
        [SugarColumn(ColumnName = "CreateUser")]        
        public string CreateUser { get; set; }
        
        /// <summary>
        /// 
        /// </summary>
        [SugarColumn(ColumnName = "CreateUserName")]        
        public string CreateUserName { get; set; }
        
        /// <summary>
        /// 
        /// </summary>
        [SugarColumn(ColumnName = "RowNo")]        
        public long? RowNo { get; set; }
        
        /// <summary>
        /// 
        /// </summary>
        [SugarColumn(ColumnName = "dbDate")]        
        public DateTime? DbDate { get; set; }

        /// <summary>
        /// 所属公司Id
        /// </summary>
        [SugarColumn(ColumnName = "CompanyId")]
        public string CompanyId { get; set; }

        /// <summary>
        /// 公司名称
        /// </summary>
        [SugarColumn(ColumnName = "CompanyName")]
        public string CompanyName { get; set; }

        /// <summary>
        /// 创建
        /// </summary>
        public virtual void Create()
        {
            var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
            var userName = App.User.FindFirst(ClaimConst.CLAINM_REALNAME)?.Value;
            this.LogId = YitIdHelper.NextId().ToString();
            this.CreateDate = DateTime.Now;
            if (!string.IsNullOrEmpty(userId))
            {
                this.CreateUser = CreateUser == null ? userId : CreateUser;
                this.CreateUserName = CreateUserName == null ? userName : CreateUserName;
            }
        }

    }
}